package com.sinosoft.brokerchannel.base.common;


import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 功能：  这是一个常量类,所有常量在此定义
 * @author shilk
 */
public class ChannelConstants {
	
	private ChannelConstants() {
		
	}
	
	/**
	 * 公共返回信息,这里约定了本系统返回给客户的所有异常
	 * 0异常的情况请大家慎用
	 */
	public enum ExceptionResult {
		/**
		 *
		 */
		SUCCESS("0000", "成功"),
		NOTNULLCOMIDERROR("0001", "渠道编码不能为空"),
		NOTNULLFIELDERROR("0002", "获取请求报文失败"),
		AESERROR("0003", "AES数据加解密异常"),
        CHANNELNOTNULL("0004","请求报文里Channel信息不能为空"),
        BEANTOJSONERROR("0005", "对象转换为json异常"),
        JSONTOBEANERROR("0006", "json字符串转java对象异常"),
        JSON2XMLERROE("0007", "JSON转换为XML时异常"),
        LOADREQDATA("0008", "获取请求报文异常 "),
        NEWTOOLUTILS("0009", "该类不允许new"),
        DATEFORMATERROR("0010", "Date时间格式不正确"),
        XML2JSONERROR("0011", "XML转换为JSON时异常"),
        BEANTOXMLERROR("0012", "将XML转换为对象时异常"),
		IMAGEDOWNERROE("0013", "图片文件下载异常 "),
		SOAPTOSOAPMESSAGE("0014", "soap字符串格式化为SOAPMessage"),
		ERROR("9999", "系统异常，请联系管理员！");
		
		private String code;
		private String message;
		
		ExceptionResult(String code, String message){
			this.code=code;
			this.message=message;
		}
		
		public String getCode() {
			return this.code;
		}
		public String getMessage() {
			return this.message;
		}
		
		@Override
		public String toString() {
			return this.message;
		}
	}

    public static final String FEGIN_CALL_BACK = "is fall back";

      
    /** XML转JSON List节点配置  */
    public static final List<String> XML_TO_JSON_NODE = new ArrayList<>();
    static {
    	XML_TO_JSON_NODE.add("package");
    	XML_TO_JSON_NODE.add("insured");
    	XML_TO_JSON_NODE.add("imageList");
    	XML_TO_JSON_NODE.add("statusList");
    	XML_TO_JSON_NODE.add("image");
    	XML_TO_JSON_NODE.add("claimAudit");
		XML_TO_JSON_NODE.add("picInfos");
    }
    
    /** XML转JSON Data节点配置  */
    public static final List<String> XML_TO_JSON_DATANODE = new ArrayList<>();
    static {
    	XML_TO_JSON_DATANODE.add("header");
    	XML_TO_JSON_DATANODE.add("reportCase");
    	XML_TO_JSON_DATANODE.add("request");
    	XML_TO_JSON_DATANODE.add("packageList");
    	XML_TO_JSON_DATANODE.add("Content");
    	XML_TO_JSON_DATANODE.add("responsehead");
    	XML_TO_JSON_DATANODE.add("PACKET");
    	XML_TO_JSON_DATANODE.add("payee");
    	XML_TO_JSON_DATANODE.add("response");
    	XML_TO_JSON_DATANODE.add("Head");
    	XML_TO_JSON_DATANODE.add("Body");
    	XML_TO_JSON_DATANODE.add("ReservedInfo");
    	XML_TO_JSON_DATANODE.add("Packet");
    }

	/**
	 * 功能： 接口列表
	 * @author shilk
	 */
	public enum requestTypeEnum{
		REQUEST_TYPE_POILCYINFO("POLICECHECKTRUE","保单验真"),
		REQUEST_TYPE_PHOTOPUSH("IMAGETOEBAO","照片信息推送核心");

		private String key;
		private String value;

		private requestTypeEnum(String key , String value) {
			this.key = key;
			this.value = value;
		}

		public static String getValue(String key ) {
			for(requestTypeEnum c : requestTypeEnum.values()) {
				if(c.getKey().equals(key)) {
					return c.value;
				}
			}
			return "";
		}

		public String getKey(){
			return this.key;
		}
		public String getValue(){
			return this.value;
		}

		@Override
		public String toString(){
			return this.value;
		}
	}

	/**
	 * 对象赋值List实际对象配置
	 */
	public final static Map<String,String> BEANCOPIRE = new HashMap<>();
	static{
		BEANCOPIRE.put("com.answern.carclaimchannel.health.vo.ReportCustomerInfoVO","com.ebao.ls.pa.claim.service.registration.vo.CustomerInfo");
		BEANCOPIRE.put("com.ebao.ls.clm.daTong.policy.entry.CoverageVo","com.sinosoft.brokerchannel.health.vo.PolicyInfoItemResVO");
	}

	/**
	 * logger输出异常信息是头信息
	 */
	public static final String EXCEPTION_LOG = "异常信息：";

    /**
     * @see feign 请求类型
     * @author wem
     */
    public enum FeignType {
        /**
         *
         */
        REPORT_SUBMIT("0", "接口1"),
        POLICY_QUERY("1","接口2");
        /**
         *普通方法
         */
        public static String getFeignTypeValue(String key) {
            for (FeignType c : FeignType.values()) {
                if (c.getkey().equals(key)) {
                    return c.value;
                }
            }
            return null;
        }
        private String key;
        private String value;

        private FeignType(String key, String value) {
            this.key=key;
            this.value=value;
        }

        public String getkey() {
            return this.key;
        }
        public String getvalue() {
            return this.value;
        }

        @Override
        public String toString() {
            return this.value;
        }
    }
	/**
	 * 系统来源信息配置
	 * @author lu
	 *
	 */
	public enum SourceEnum {
		B2B_PC("1", new Long(60), "pc端token失效时间:1小时"),
		B2B_MOBILE("2", new Long(60), "手机端token失效时间:1小时"),
		B2B_QRCODE("3", new Long(518400), "二维码出单系统token失效时间:无"),
		B2B_PLATFORM("4", new Long(60), "管理系统token失效时间:1小时"),
		PIN_PIPE("5", null, "销管系统"),
		PIN_CHANNEL("6", null, "渠道系统"),
		PIN_DUBBO("7", null, "DUBBO系统"),
		;

		private final String desc; //描述
		private final Long expiresIn;//token失效时间
		private final String code; //系统代码

		SourceEnum(String code, Long expiresIn, String desc) {
			this.desc = desc;
			this.expiresIn = expiresIn;
			this.code = code;
		}

		public Long expiresIn() {
			return this.expiresIn;
		}

		public String desc() {
			return this.desc;
		}

		public String code() {
			return this.code;
		}

	}
}
